home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / CodeWarrior Lite / Metrowerks C⁄C++ Lite / Headers / Universal Headers 2.0.1f / Speech.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-03-22  |  13.7 KB  |  384 lines  |  [TEXT/MMCC]

  1. /*
  2.      File:        Speech.h
  3.  
  4.      Contains:    Speech Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Package:    Universal Interfaces 2.0 in “MPW Latest” on ETO #17
  8.  
  9.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  10.                  All rights reserved.
  11.  
  12.      Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  13.                  stack.  Include the file and version information (from above)
  14.                  in the problem description and send to:
  15.                      Internet:    apple.bugs@applelink.apple.com
  16.                      AppleLink:    APPLE.BUGS
  17.  
  18. */
  19.  
  20. #ifndef __SPEECH__
  21. #define __SPEECH__
  22.  
  23.  
  24. #ifndef __TYPES__
  25. #include <Types.h>
  26. #endif
  27. /*    #include <ConditionalMacros.h>                                */
  28.  
  29. #ifndef __MEMORY__
  30. #include <Memory.h>
  31. #endif
  32. /*    #include <MixedMode.h>                                        */
  33.  
  34. #ifndef __FILES__
  35. #include <Files.h>
  36. #endif
  37. /*    #include <OSUtils.h>                                        */
  38.  
  39. #ifdef __cplusplus
  40. extern "C" {
  41. #endif
  42.  
  43. #if PRAGMA_ALIGN_SUPPORTED
  44. #pragma options align=mac68k
  45. #endif
  46.  
  47. #if PRAGMA_IMPORT_SUPPORTED
  48. #pragma import on
  49. #endif
  50.  
  51.  
  52. enum {
  53.     kTextToSpeechSynthType        = 'ttsc',
  54.     kTextToSpeechVoiceType        = 'ttvd',
  55.     kTextToSpeechVoiceFileType    = 'ttvf',
  56.     kTextToSpeechVoiceBundleType = 'ttvb'
  57. };
  58.  
  59. enum {
  60.     kNoEndingProsody            = 1,
  61.     kNoSpeechInterrupt            = 2,
  62.     kPreflightThenPause            = 4
  63. };
  64.  
  65. enum {
  66.     kImmediate                    = 0,
  67.     kEndOfWord                    = 1,
  68.     kEndOfSentence                = 2
  69. };
  70.  
  71. /*------------------------------------------*/
  72. /* GetSpeechInfo & SetSpeechInfo selectors    */
  73. /*------------------------------------------*/
  74. enum {
  75.     soStatus                    = 'stat',
  76.     soErrors                    = 'erro',
  77.     soInputMode                    = 'inpt',
  78.     soCharacterMode                = 'char',
  79.     soNumberMode                = 'nmbr',
  80.     soRate                        = 'rate',
  81.     soPitchBase                    = 'pbas',
  82.     soPitchMod                    = 'pmod',
  83.     soVolume                    = 'volm',
  84.     soSynthType                    = 'vers',
  85.     soRecentSync                = 'sync',
  86.     soPhonemeSymbols            = 'phsy',
  87.     soCurrentVoice                = 'cvox',
  88.     soCommandDelimiter            = 'dlim',
  89.     soReset                        = 'rset',
  90.     soCurrentA5                    = 'myA5',
  91.     soRefCon                    = 'refc',
  92.     soTextDoneCallBack            = 'tdcb',
  93.     soSpeechDoneCallBack        = 'sdcb',
  94.     soSyncCallBack                = 'sycb',
  95.     soErrorCallBack                = 'ercb',
  96.     soPhonemeCallBack            = 'phcb',
  97.     soWordCallBack                = 'wdcb',
  98.     soSynthExtension            = 'xtnd',
  99.     soSoundOutput                = 'sndo'
  100. };
  101.  
  102. /*------------------------------------------*/
  103. /* Speaking Mode Constants                     */
  104. /*------------------------------------------*/
  105. enum {
  106.     modeText                    = 'TEXT',                        /* input mode constants                     */
  107.     modePhonemes                = 'PHON',
  108.     modeNormal                    = 'NORM',                        /* character mode and number mode constants */
  109.     modeLiteral                    = 'LTRL'
  110. };
  111.  
  112. enum {
  113.     soVoiceDescription            = 'info',
  114.     soVoiceFile                    = 'fref'
  115. };
  116.  
  117. struct SpeechChannelRecord {
  118.     long                            data[1];
  119. };
  120. typedef struct SpeechChannelRecord SpeechChannelRecord;
  121.  
  122. typedef SpeechChannelRecord *SpeechChannel;
  123.  
  124. struct VoiceSpec {
  125.     OSType                            creator;
  126.     OSType                            id;
  127. };
  128. typedef struct VoiceSpec VoiceSpec;
  129.  
  130.  
  131. enum {
  132.     kNeuter                        = 0,
  133.     kMale                        = 1,
  134.     kFemale                        = 2
  135. };
  136.  
  137. struct VoiceDescription {
  138.     long                            length;
  139.     VoiceSpec                        voice;
  140.     long                            version;
  141.     Str63                            name;
  142.     Str255                            comment;
  143.     short                            gender;
  144.     short                            age;
  145.     short                            script;
  146.     short                            language;
  147.     short                            region;
  148.     long                            reserved[4];
  149. };
  150. typedef struct VoiceDescription VoiceDescription;
  151.  
  152. struct VoiceFileInfo {
  153.     FSSpec                            fileSpec;
  154.     short                            resID;
  155. };
  156. typedef struct VoiceFileInfo VoiceFileInfo;
  157.  
  158. struct SpeechStatusInfo {
  159.     Boolean                            outputBusy;
  160.     Boolean                            outputPaused;
  161.     long                            inputBytesLeft;
  162.     short                            phonemeCode;
  163. };
  164. typedef struct SpeechStatusInfo SpeechStatusInfo;
  165.  
  166. struct SpeechErrorInfo {
  167.     short                            count;
  168.     OSErr                            oldest;
  169.     long                            oldPos;
  170.     OSErr                            newest;
  171.     long                            newPos;
  172. };
  173. typedef struct SpeechErrorInfo SpeechErrorInfo;
  174.  
  175. struct SpeechVersionInfo {
  176.     OSType                            synthType;
  177.     OSType                            synthSubType;
  178.     OSType                            synthManufacturer;
  179.     long                            synthFlags;
  180.     NumVersion                        synthVersion;
  181. };
  182. typedef struct SpeechVersionInfo SpeechVersionInfo;
  183.  
  184. struct PhonemeInfo {
  185.     short                            opcode;
  186.     Str15                            phStr;
  187.     Str31                            exampleStr;
  188.     short                            hiliteStart;
  189.     short                            hiliteEnd;
  190. };
  191. typedef struct PhonemeInfo PhonemeInfo;
  192.  
  193. struct PhonemeDescriptor {
  194.     short                            phonemeCount;
  195.     PhonemeInfo                        thePhonemes[1];
  196. };
  197. typedef struct PhonemeDescriptor PhonemeDescriptor;
  198.  
  199. struct SpeechXtndData {
  200.     OSType                            synthCreator;
  201.     Byte                            synthData[2];
  202. };
  203. typedef struct SpeechXtndData SpeechXtndData;
  204.  
  205. struct DelimiterInfo {
  206.     Byte                            startDelimiter[2];
  207.     Byte                            endDelimiter[2];
  208. };
  209. typedef struct DelimiterInfo DelimiterInfo;
  210.  
  211. typedef pascal void (*SpeechTextDoneProcPtr)(SpeechChannel parameter0, long parameter1, Ptr *parameter2, long *parameter3, long *parameter4);
  212. typedef pascal void (*SpeechDoneProcPtr)(SpeechChannel parameter0, long parameter1);
  213. typedef pascal void (*SpeechSyncProcPtr)(SpeechChannel parameter0, long parameter1, OSType parameter2);
  214. typedef pascal void (*SpeechErrorProcPtr)(SpeechChannel parameter0, long parameter1, OSErr parameter2, long parameter3);
  215. typedef pascal void (*SpeechPhonemeProcPtr)(SpeechChannel parameter0, long parameter1, short parameter2);
  216. typedef pascal void (*SpeechWordProcPtr)(SpeechChannel parameter0, long parameter1, long parameter2, short parameter3);
  217.  
  218. #if GENERATINGCFM
  219. typedef UniversalProcPtr SpeechTextDoneUPP;
  220. typedef UniversalProcPtr SpeechDoneUPP;
  221. typedef UniversalProcPtr SpeechSyncUPP;
  222. typedef UniversalProcPtr SpeechErrorUPP;
  223. typedef UniversalProcPtr SpeechPhonemeUPP;
  224. typedef UniversalProcPtr SpeechWordUPP;
  225. #else
  226. typedef SpeechTextDoneProcPtr SpeechTextDoneUPP;
  227. typedef SpeechDoneProcPtr SpeechDoneUPP;
  228. typedef SpeechSyncProcPtr SpeechSyncUPP;
  229. typedef SpeechErrorProcPtr SpeechErrorUPP;
  230. typedef SpeechPhonemeProcPtr SpeechPhonemeUPP;
  231. typedef SpeechWordProcPtr SpeechWordUPP;
  232. #endif
  233.  
  234. enum {
  235.     uppSpeechTextDoneProcInfo = kPascalStackBased
  236.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(SpeechChannel)))
  237.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(long)))
  238.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(Ptr*)))
  239.          | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(long*)))
  240.          | STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(long*))),
  241.     uppSpeechDoneProcInfo = kPascalStackBased
  242.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(SpeechChannel)))
  243.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(long))),
  244.     uppSpeechSyncProcInfo = kPascalStackBased
  245.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(SpeechChannel)))
  246.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(long)))
  247.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(OSType))),
  248.     uppSpeechErrorProcInfo = kPascalStackBased
  249.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(SpeechChannel)))
  250.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(long)))
  251.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(OSErr)))
  252.          | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(long))),
  253.     uppSpeechPhonemeProcInfo = kPascalStackBased
  254.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(SpeechChannel)))
  255.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(long)))
  256.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(short))),
  257.     uppSpeechWordProcInfo = kPascalStackBased
  258.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(SpeechChannel)))
  259.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(long)))
  260.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(long)))
  261.          | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(short)))
  262. };
  263.  
  264. #if GENERATINGCFM
  265. #define NewSpeechTextDoneProc(userRoutine)        \
  266.         (SpeechTextDoneUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppSpeechTextDoneProcInfo, GetCurrentArchitecture())
  267. #define NewSpeechDoneProc(userRoutine)        \
  268.         (SpeechDoneUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppSpeechDoneProcInfo, GetCurrentArchitecture())
  269. #define NewSpeechSyncProc(userRoutine)        \
  270.         (SpeechSyncUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppSpeechSyncProcInfo, GetCurrentArchitecture())
  271. #define NewSpeechErrorProc(userRoutine)        \
  272.         (SpeechErrorUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppSpeechErrorProcInfo, GetCurrentArchitecture())
  273. #define NewSpeechPhonemeProc(userRoutine)        \
  274.         (SpeechPhonemeUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppSpeechPhonemeProcInfo, GetCurrentArchitecture())
  275. #define NewSpeechWordProc(userRoutine)        \
  276.         (SpeechWordUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppSpeechWordProcInfo, GetCurrentArchitecture())
  277. #else
  278. #define NewSpeechTextDoneProc(userRoutine)        \
  279.         ((SpeechTextDoneUPP) (userRoutine))
  280. #define NewSpeechDoneProc(userRoutine)        \
  281.         ((SpeechDoneUPP) (userRoutine))
  282. #define NewSpeechSyncProc(userRoutine)        \
  283.         ((SpeechSyncUPP) (userRoutine))
  284. #define NewSpeechErrorProc(userRoutine)        \
  285.         ((SpeechErrorUPP) (userRoutine))
  286. #define NewSpeechPhonemeProc(userRoutine)        \
  287.         ((SpeechPhonemeUPP) (userRoutine))
  288. #define NewSpeechWordProc(userRoutine)        \
  289.         ((SpeechWordUPP) (userRoutine))
  290. #endif
  291.  
  292. #if GENERATINGCFM
  293. #define CallSpeechTextDoneProc(userRoutine, parameter0, parameter1, parameter2, parameter3, parameter4)        \
  294.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppSpeechTextDoneProcInfo, (parameter0), (parameter1), (parameter2), (parameter3), (parameter4))
  295. #define CallSpeechDoneProc(userRoutine, parameter0, parameter1)        \
  296.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppSpeechDoneProcInfo, (parameter0), (parameter1))
  297. #define CallSpeechSyncProc(userRoutine, parameter0, parameter1, parameter2)        \
  298.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppSpeechSyncProcInfo, (parameter0), (parameter1), (parameter2))
  299. #define CallSpeechErrorProc(userRoutine, parameter0, parameter1, parameter2, parameter3)        \
  300.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppSpeechErrorProcInfo, (parameter0), (parameter1), (parameter2), (parameter3))
  301. #define CallSpeechPhonemeProc(userRoutine, parameter0, parameter1, parameter2)        \
  302.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppSpeechPhonemeProcInfo, (parameter0), (parameter1), (parameter2))
  303. #define CallSpeechWordProc(userRoutine, parameter0, parameter1, parameter2, parameter3)        \
  304.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppSpeechWordProcInfo, (parameter0), (parameter1), (parameter2), (parameter3))
  305. #else
  306. #define CallSpeechTextDoneProc(userRoutine, parameter0, parameter1, parameter2, parameter3, parameter4)        \
  307.         (*(userRoutine))((parameter0), (parameter1), (parameter2), (parameter3), (parameter4))
  308. #define CallSpeechDoneProc(userRoutine, parameter0, parameter1)        \
  309.         (*(userRoutine))((parameter0), (parameter1))
  310. #define CallSpeechSyncProc(userRoutine, parameter0, parameter1, parameter2)        \
  311.         (*(userRoutine))((parameter0), (parameter1), (parameter2))
  312. #define CallSpeechErrorProc(userRoutine, parameter0, parameter1, parameter2, parameter3)        \
  313.         (*(userRoutine))((parameter0), (parameter1), (parameter2), (parameter3))
  314. #define CallSpeechPhonemeProc(userRoutine, parameter0, parameter1, parameter2)        \
  315.         (*(userRoutine))((parameter0), (parameter1), (parameter2))
  316. #define CallSpeechWordProc(userRoutine, parameter0, parameter1, parameter2, parameter3)        \
  317.         (*(userRoutine))((parameter0), (parameter1), (parameter2), (parameter3))
  318. #endif
  319.  
  320. extern pascal NumVersion SpeechManagerVersion(void)
  321.  FOURWORDINLINE(0x203C, 0x0000, 0x000C, 0xA800);
  322. extern pascal OSErr MakeVoiceSpec(OSType creator, OSType id, VoiceSpec *voice)
  323.  FOURWORDINLINE(0x203C, 0x0604, 0x000C, 0xA800);
  324. extern pascal OSErr CountVoices(short *numVoices)
  325.  FOURWORDINLINE(0x203C, 0x0108, 0x000C, 0xA800);
  326. extern pascal OSErr GetIndVoice(short index, VoiceSpec *voice)
  327.  FOURWORDINLINE(0x203C, 0x030C, 0x000C, 0xA800);
  328. extern pascal OSErr GetVoiceDescription(VoiceSpec *voice, VoiceDescription *info, long infoLength)
  329.  FOURWORDINLINE(0x203C, 0x0610, 0x000C, 0xA800);
  330. extern pascal OSErr GetVoiceInfo(VoiceSpec *voice, OSType selector, void *voiceInfo)
  331.  FOURWORDINLINE(0x203C, 0x0614, 0x000C, 0xA800);
  332. extern pascal OSErr NewSpeechChannel(VoiceSpec *voice, SpeechChannel *chan)
  333.  FOURWORDINLINE(0x203C, 0x0418, 0x000C, 0xA800);
  334. extern pascal OSErr DisposeSpeechChannel(SpeechChannel chan)
  335.  FOURWORDINLINE(0x203C, 0x021C, 0x000C, 0xA800);
  336. extern pascal OSErr SpeakString(StringPtr s)
  337.  FOURWORDINLINE(0x203C, 0x0220, 0x000C, 0xA800);
  338. extern pascal OSErr SpeakText(SpeechChannel chan, Ptr textBuf, long textBytes)
  339.  FOURWORDINLINE(0x203C, 0x0624, 0x000C, 0xA800);
  340. extern pascal OSErr SpeakBuffer(SpeechChannel chan, Ptr textBuf, long textBytes, long controlFlags)
  341.  FOURWORDINLINE(0x203C, 0x0828, 0x000C, 0xA800);
  342. extern pascal OSErr StopSpeech(SpeechChannel chan)
  343.  FOURWORDINLINE(0x203C, 0x022C, 0x000C, 0xA800);
  344. extern pascal OSErr StopSpeechAt(SpeechChannel chan, long whereToStop)
  345.  FOURWORDINLINE(0x203C, 0x0430, 0x000C, 0xA800);
  346. extern pascal OSErr PauseSpeechAt(SpeechChannel chan, long whereToPause)
  347.  FOURWORDINLINE(0x203C, 0x0434, 0x000C, 0xA800);
  348. extern pascal OSErr ContinueSpeech(SpeechChannel chan)
  349.  FOURWORDINLINE(0x203C, 0x0238, 0x000C, 0xA800);
  350. extern pascal short SpeechBusy(void)
  351.  FOURWORDINLINE(0x203C, 0x003C, 0x000C, 0xA800);
  352. extern pascal short SpeechBusySystemWide(void)
  353.  FOURWORDINLINE(0x203C, 0x0040, 0x000C, 0xA800);
  354. extern pascal OSErr SetSpeechRate(SpeechChannel chan, Fixed rate)
  355.  FOURWORDINLINE(0x203C, 0x0444, 0x000C, 0xA800);
  356. extern pascal OSErr GetSpeechRate(SpeechChannel chan, Fixed *rate)
  357.  FOURWORDINLINE(0x203C, 0x0448, 0x000C, 0xA800);
  358. extern pascal OSErr SetSpeechPitch(SpeechChannel chan, Fixed pitch)
  359.  FOURWORDINLINE(0x203C, 0x044C, 0x000C, 0xA800);
  360. extern pascal OSErr GetSpeechPitch(SpeechChannel chan, Fixed *pitch)
  361.  FOURWORDINLINE(0x203C, 0x0450, 0x000C, 0xA800);
  362. extern pascal OSErr SetSpeechInfo(SpeechChannel chan, OSType selector, void *speechInfo)
  363.  FOURWORDINLINE(0x203C, 0x0654, 0x000C, 0xA800);
  364. extern pascal OSErr GetSpeechInfo(SpeechChannel chan, OSType selector, void *speechInfo)
  365.  FOURWORDINLINE(0x203C, 0x0658, 0x000C, 0xA800);
  366. extern pascal OSErr TextToPhonemes(SpeechChannel chan, Ptr textBuf, long textBytes, Handle phonemeBuf, long *phonemeBytes)
  367.  FOURWORDINLINE(0x203C, 0x0A5C, 0x000C, 0xA800);
  368. extern pascal OSErr UseDictionary(SpeechChannel chan, Handle dictionary)
  369.  FOURWORDINLINE(0x203C, 0x0460, 0x000C, 0xA800);
  370.  
  371. #if PRAGMA_IMPORT_SUPPORTED
  372. #pragma import off
  373. #endif
  374.  
  375. #if PRAGMA_ALIGN_SUPPORTED
  376. #pragma options align=reset
  377. #endif
  378.  
  379. #ifdef __cplusplus
  380. }
  381. #endif
  382.  
  383. #endif /* __SPEECH__ */
  384.